package com.example.mynote.ui;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

public class MyDataViewModel extends ViewModel {
    //用户登录状态
    private MutableLiveData<Boolean> ifLogin;
    //开始下载
    private MutableLiveData<String> startDownload;
    //开始下载
    private MutableLiveData<String> startUpload;

    public LiveData<Boolean> getIfLogin() {
        if (ifLogin == null) {
            ifLogin = new MutableLiveData<>();
        }
        return ifLogin;
    }

    public LiveData<String> getStartDownload() {
        if (startDownload == null) {
            startDownload = new MutableLiveData<>();
        }
        return startDownload;
    }

    public LiveData<String> getStartUpload() {
        if (startUpload == null) {
            startUpload = new MutableLiveData<>();
        }
        return startUpload;
    }

    public void setIfLogin(Boolean ifLogin) {
        this.ifLogin.setValue(ifLogin);
    }

    public void setStartDownload(String startDownload) {
        this.startDownload.setValue(startDownload);
    }

    public void setStartUpload(String startUpload) {
        this.startUpload.setValue(startUpload);
    }

    @Override
    protected void onCleared() {
        super.onCleared();
        ifLogin = null;
        startDownload=null;
        startUpload=null;
    }
}
